/* rcshgwa2.p - Shipper Gateway Subprogram                                   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/* $Revision: 1.11.2.9 $                                                 */
/*V8:ConvertMode=NoConvert                                                   */

/* REVISION: 8.5      LAST MODIFIED: 05/22/96           BY: GWM *J0NC*       */
/* REVISION: 8.6      LAST MODIFIED: 10/31/96   BY: *K003* Steve Goeke       */
/* REVISION: 8.6      LAST MODIFIED: 11/11/96   BY: *K003* Vinay Nayak-Sujir */
/* REVISION: 8.6      LAST MODIFIED: 12/02/97   BY: *J277* Manish K.         */
/* REVISION: 8.6      LAST MODIFIED: 12/13/97   BY: *J20Q* Aruna Patil       */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane         */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan        */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan        */
/* REVISION: 8.6E     LAST MODIFIED: 11/18/98   BY: *J34W* Surekha Joshi     */
/* REVISION: 8.6E     LAST MODIFIED: 11/24/98   BY: *J35C* Surekha Joshi     */
/* REVISION: 8.6E     LAST MODIFIED: 12/23/98   BY: *J375* Surekha Joshi     */
/* REVISION: 8.6E     LAST MODIFIED: 09/25/99   BY: *J3LP* Anup Pereira      */
/* REVISION: 9.1      LAST MODIFIED: 11/09/99   BY: *N004* Steve Nugent      */
/* REVISION: 9.1      LAST MODIFIED: 05/11/00   BY: *J3PW* Manish K.         */
/* REVISION: 9.1      LAST MODIFIED: 07/19/00   BY: *N0GF* Mudit Mehta       */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb               */
/* Revision: 1.11.2.7       BY:Patrick Rowan    DATE: 01/04/01   ECO: *N0VH* */
/* Old ECO marker removed, but no ECO header exists *K005*                   */
/* Revision: 1.11.2.8       BY: Dan Herman     DATE: 07/06/01   ECO: *P007*  */
/* $Revision: 1.11.2.9 $      BY: Katie Hilbert  DATE: 04/15/02   ECO: *P03J*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

   {mfdeclre.i}
   {gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input parameter v_ship_to like so_ship no-undo.

   /* LOCAL VARIABLES */
define variable wt_conv       as decimal       no-undo.
define variable vol_conv      as decimal       no-undo.
define variable save_recid    as recid         no-undo.
define variable qty_conv      as decimal       no-undo.
define variable v_par_recid   as   recid       no-undo.
define variable v_shipgrp     like abs_inv_mov no-undo.
define variable v_other_so    like so_nbr      no-undo.
define variable v_cons_ok     like mfc_logical no-undo.
define variable l_recid       as   recid       no-undo.
define variable l_shipto_id   like ad_addr     no-undo.
define variable l_addr        like ad_addr     no-undo.
define variable l_abs_recid   as   recid       no-undo.
define variable l_abs_tare_wt like abs_nwt     no-undo.
define variable l_abs_nwt     like abs_nwt     no-undo.
define variable l_abs_gwt     like abs_gwt     no-undo.
define variable abs_recid     as recid         no-undo.
define variable create_abs    like mfc_logical no-undo.
define variable errors        like mfc_logical initial no no-undo.
define variable using_seq_schedules like mfc_logical initial no no-undo.

/* VARIABLE DEFINITIONS FOR gpfile.i */
{gpfilev.i}

/* SHARED VARIABLES */
{rcshgw.i}
{rcinvtbl.i new}

/* BUFFERS */
define buffer ship_record for abs_mstr.
define buffer anc_abs_mstr for abs_mstr.
define buffer top_ship    for abs_mstr.

/* DETERMINE IF SEQUENCE SCHEDULES IS INSTALLED */
{gpfile.i &file_name = """"rcf_ctrl""""}
if can-find (mfc_ctrl where
   mfc_field = "enable_sequence_schedules" and
   mfc_logical) and file_found then
   using_seq_schedules = yes.

/* DETERMINE IF LINE CHARGES IS ENABLED */
{cclc.i}

/* Find top-level parent shipper or preshipper */
{gprun.i ""gpabspar.p""
   "(abs_recno, 'PSR', false, output v_par_recid)" }

/* Get the shipper or preshipper */
find top_ship no-lock where recid(top_ship) = v_par_recid no-error.

/* Now find the direct parent */
find ship_record where recid(ship_record) = abs_recno
   no-lock no-error.

/* VALIDATE THE ITEM TYPE DATA */
if ship_type = "I" then do:

   /* VERIFY ONLY */
   if verify_only then do:

      find first abs_mstr
         where abs_mstr.abs_shipfrom = ship_from
           and abs_mstr.abs_par_id = ship_parent
           and abs_mstr.abs_item = ship_part
           and abs_mstr.abs_lot = ship_lot
           and abs_mstr.abs_ref = ship_ref
           and abs_mstr.abs_qty = decimal(ship_qty)
         no-lock no-error.

      if available abs_mstr then do:
         if not ship_parent begins("C") then do:
            /* THE ITEM/QTY IS ON THE SHIPPER */
            {pxmsg.i &MSGNUM=8279 &ERRORLEVEL=1}
         end.
         else do:
            /* THE ITEM/QTY IS IN THE CONTAINER */
            {pxmsg.i &MSGNUM=8280 &ERRORLEVEL=1}
         end.
      end.
      else do:
         /* THE ITEM/QTY WAS NOT FOUND ON THE SHIPPER/CONTAINER*/
         {pxmsg.i &MSGNUM=8281 &ERRORLEVEL=4}
      end.

      return.
   end. /* IF VERIFY_ONLY */

   /* CREATE ITEM RECORD */

   /* VALIDATE THE PART NUMBER */
   find pt_mstr where pt_part = ship_part no-lock no-error.

   if not available pt_mstr or ship_part = "" then do:

      /* BAD PART NUMBER IN THE INPUT DATA */
      {pxmsg.i &MSGNUM=8282 &ERRORLEVEL=4}
      error_msg = error_msg + 1.
   end.

   /* ASSIGN ITEM DEFAULTS */

   else do:
      if ship_site    = "" then ship_site    = pt_site.
      if ship_loc     = "" then ship_loc     = pt_loc.
      if ship_qty_um  = "" then ship_qty_um  = pt_um.
      if ship_wght_um = "" then ship_wght_um = pt_net_wt_um.
      if ship_vol_um  = "" then ship_vol_um  = pt_size_um.
   end.

   /* VALIDATE THE SITE */
   find si_mstr where si_site = ship_site no-lock no-error.
   if not available si_mstr or ship_site = "" then do:
      /* SITE DOES NOT EXIST */
      {pxmsg.i &MSGNUM=8273 &ERRORLEVEL=1}
      error_msg = error_msg + 1.
   end.

   /* VALIDATE WHETHER AUTO TRANSFER IS ALLOWED */

   if available top_ship and top_ship.abs_inv_mov <> "" and
      ship_from <> ship_site
   then do:

      {gprun.i ""gpgetgrp.p""
         "(ship_site, ship_from, output v_shipgrp)"}

      if can-find(
         sg_mstr where
         sg_grp = v_shipgrp and sg_auto_tr = false)
      then do:
         /* AUTOMATIC TRANSFER FROM SITE # TO SITE # PROHIBITED */
         {pxmsg.i &MSGNUM = 5845 &ERRORLEVEL = 4
                  &MSGARG1 = ship_site &MSGARG2 = ship_from}
         error_msg = error_msg + 1.

      end.  /* if can-find */
   end.  /* if available top_ship */

   /* VALIDATE THE LOCATION */
   if ship_loc <> "" then
   do:
      find loc_mstr
         where loc_site = ship_site
           and loc_loc = ship_loc
         no-lock no-error.

      if not available loc_mstr then do:

         if available si_mstr and si_auto_loc
         then do:
            /* LOCATION DOES NOT EXIST AT THIS SITE */
            {pxmsg.i &MSGNUM=8292 &ERRORLEVEL=2}
         end. /* SI_AUTO_LOC */

         if available si_mstr and not (si_auto_loc)
         then do:
            /* LOCATION DOES NOT EXIST AT THIS SITE */
            {pxmsg.i &MSGNUM=8292 &ERRORLEVEL=1}
            error_msg = error_msg + 1.
         end. /* NOT SI_AUTO_LOC */

      end. /* IF NOT AVAILABLE LOC_MSTR */

   end. /* IF SHIP_LOC <> "" */

   /* VALIDATE THE ORDER */

   if ship_order <> "" and available ship_record and available top_ship
   then do:

      if top_ship.abs_type = "S" then do:

         find so_mstr where so_nbr = ship_order no-lock no-error.

         if not available so_mstr then do:
            /* SALES ORDER DOES NOT EXIST */
            {pxmsg.i &MSGNUM=609 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.

         /* IF ABS_SHIPTO IS A DOCK ADDRESS FIND THE SHIP-TO OF THE DOCK */
         /* AND THEN COMPARE IT WITH  SO SHIP-TO                         */

         for first ad_mstr
            fields (ad_addr ad_ref)
            where ad_addr = ship_record.abs_shipto no-lock:
         end. /* FOR FIRST AD_MSTR */

         for first ls_mstr
            fields (ls_addr ls_type)
            where ls_addr  = ad_addr and
               (ls_type = "ship-to" or ls_type = "customer")
         no-lock:
         end. /* FOR FIRST LS_MSTR */

         do while not available ls_mstr and right-trim(ad_ref) > "":
            l_addr = ad_ref.

            for first ad_mstr
               fields (ad_addr ad_ref)
               where ad_addr = l_addr no-lock:
            end. /* FOR FIRST AD_MSTR */

            for first ls_mstr
               fields (ls_addr ls_type)
               where ls_addr  = ad_addr and
                  (ls_type = "ship-to" or ls_type = "customer")
            no-lock:
            end. /* FOR FIRST LS_MSTR */

         end. /* DO WHILE NOT AVAILABLE LS_MSTR */
         l_shipto_id = ad_addr.

         if (so_ship <> l_shipto_id) and
            (so_ship <> ship_record.abs_shipto)
         then do:
            /* SALES ORDER AND SHIPTO DO NOT MATCH */
            {pxmsg.i &MSGNUM=8283 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.

         find sod_det where sod_nbr = ship_order
            and sod_line = integer(ship_line) no-lock no-error.

         if not available sod_det then do:
            /* SALES ORDER LINE DOES NOT EXIST */
            {pxmsg.i &MSGNUM=6011 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.
         else
         if not sod_sched   and
            not sod_confirm
         then do:
            /* SALES ORDER NOT CONFIRMED */
            {pxmsg.i &MSGNUM=621 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end. /* IF NOT SOD_SCHED AND ... */

      end. /* ABS_TYPE = "S" */

      if top_ship.abs_type = "R" then do:

         find po_mstr where po_nbr = ship_order no-lock no-error.

         if not available po_mstr then do:
            /* PURCHASE ORDER DOES NOT EXIST */
            {pxmsg.i &MSGNUM=343 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.

         find pod_det where pod_nbr = ship_order
            and pod_line = integer(ship_line) no-lock no-error.

         if not available pod_det then do:
            /* PURCHASE ORDER LINE DOES NOT EXIST */
            {pxmsg.i &MSGNUM=6011 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.

      end. /* ABS_TYPE = "R" */
   end.  /* SHIP_ORDER <> "" */

   /* NO ORDER NUMBER PROVIDED SO FIND IT */

   else
   if ship_order = "" and available ship_record and
      available top_ship
   then do:

      if top_ship.abs_type = "S" then do:

         save_recid = ?.

         MORE_THAN_ONE:
         for each sod_det where sod_part = ship_part
               and sod_contr_id = ship_cust_po
               and sod_custref = ship_cust_ref
               and sod_modelyr = ship_cust_modelyr
         no-lock:


            find so_mstr where so_nbr = sod_nbr no-lock.

            if so_ship <> ship_record.abs_shipto
               then next MORE_THAN_ONE.

            if save_recid <> ? then do:

               /* MORE THAN ONE MATCHING SALES ORDER LINE */
               /* ITEM WAS FOUND FOR THIS PART            */
               {pxmsg.i &MSGNUM=8284 &ERRORLEVEL=4}
               error_msg = error_msg + 1.
               leave MORE_THAN_ONE.
            end.

            save_recid = recid(sod_det).
         end. /* MORE_THAN_ONE */

         if save_recid = ? then do:

            /* A MATCHING SALES ORDER LINE ITEM */
            /* WAS NOT FOUND FOR THIS PART      */
            {pxmsg.i &MSGNUM=8285 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.

         /* FOUND A SOD_DET THAT CAN BE DEFAULTED */
         else do:

            find sod_det where recid(sod_det) = save_recid
               no-lock.

            if not sod_sched   and
               not sod_confirm
            then do:
               /* SALES ORDER NOT CONFIRMED */
               {pxmsg.i &MSGNUM=621 &ERRORLEVEL=4}
               error_msg = error_msg + 1.
            end. /* IF NOT SOD_SCHED AND ... */
            else
               assign
                  ship_order = sod_nbr
                  ship_line = string(sod_line).
         end.

      end. /* ABS_TYPE = "S" */

      if top_ship.abs_type = "R" then do:

         save_recid = ?.

         MORE_THAN_1:
         for each pod_det where pod_part = ship_part
               and pod_status = "" no-lock:

            find po_mstr where po_nbr = pod_nbr no-lock.

            if po_vend <> ship_record.abs_shipfrom
               then next MORE_THAN_1.

            if save_recid <> ? then do:

               /* MORE THAN ONE MATCHING PURCHASE ORDER     */
               /* LINE ITEM WAS FOUND FOR THIS PART         */
               {pxmsg.i &MSGNUM=8286 &ERRORLEVEL=4}
               error_msg = error_msg + 1.
               leave MORE_THAN_1.
            end.

            save_recid = recid(pod_det).
         end. /* MORE_THAN_1 */

         if save_recid = ? then do:

            /* A MATCHING PURCHASE ORDER LINE ITEM  */
            /* WAS NOT FOUND FOR THIS PART          */
            {pxmsg.i &MSGNUM=8287 &ERRORLEVEL=1}
            error_msg = error_msg + 1.

         end.

         /* FOUND A POD_DET THAT CAN BE DEFAULTED */
         else do:

            find pod_det
               where recid(pod_det) = save_recid no-lock.

            assign
               ship_order = pod_nbr
               ship_line = string(pod_line).
         end.

      end. /* ABS_TYPE = "R" */
   end. /* SHIP_ORDER = "" (ELSE DO) */

   if ship_order <> "" and available top_ship and
      top_ship.abs_type = "S" then do:

      /* CHECK SHIPPER CONSOLIDATION REQUIREMENTS */

      if top_ship.abs_cons_ship = "0" then do:

         run chk_abs_shp_cons(
            top_ship.abs_id, top_ship.abs_shipfrom, "", "", ship_order,
            output v_cons_ok, output v_other_so).

         if not v_cons_ok then do:
            /* MULTIPLE SOs ON SHIPPER. CONSOLIDATION NOT PERMITTED */
            {pxmsg.i &MSGNUM=5827 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.  /* if not v_cons_ok */

      end. /* if top_ship.abs_cons_ship */

      /* CHECK INVOICE CONSOLIDATION REQUIREMENTS */

      if can-find(
         df_mstr where
         df_type   = "1"                 and
         df_format = top_ship.abs_format and
         df_inv    = true)
      then do:

         run chk_abs_inv_cons(
            top_ship.abs_id, top_ship.abs_shipfrom,
            "", "", ship_order, output v_cons_ok).

         if not v_cons_ok then do:
            /* INVALID SHIPPER. SOs PROHIBIT INVOICE CONSOLIDATION */
            {pxmsg.i &MSGNUM=5999 &ERRORLEVEL=4}
            error_msg = error_msg + 1.
         end.  /* if not v_cons_ok */

      end. /* if can-find */
   end.  /* if ship_order */

   create_abs = yes.

   find abs_mstr
      where abs_mstr.abs_shipfrom = ship_record.abs_shipfrom
        and abs_mstr.abs_id = "i" + ship_record.abs_id
                                  + ship_part + ship_cust_po
                                  + ship_cust_ref + ship_cust_modelyr
                                  + ship_lot + ship_ref
      no-lock no-error.

   if available abs_mstr then do:

      if using_seq_schedules and
         can-find (first so_mstr where
            so_nbr = ship_order  and
            so_seq_order) and
         can-find (first rcs_mstr where
            rcs_shipfrom = ship_from  and
            rcs_shipto = v_ship_to  and
            rcs_active)
      then do:

         /* Accumulate the quantity shipped.             */
         abs_recid = recid(abs_mstr).
         for first abs_mstr where recid(abs_mstr) = abs_recid
               exclusive-lock:
            abs_mstr.abs_qty = abs_mstr.abs_qty + decimal(ship_qty).
         end.

         /* Process the sequence information.            */
         {gprunmo.i
            &program=""rcshgwsq.p""
            &module="ASQ"
            &param="""(input abs_recid,
                       input v_ship_to,
                       output errors)"""}

         if errors then leave.
         create_abs = no.
      end. /* if using_seq_schedules */
      else do:
         /* ITEM ALREADY EXISTS ON THE SHIPPER */
         {pxmsg.i &MSGNUM = 8288 &ERRORLEVEL = 4 &MSGARG1 = ship_part}
         error_msg = error_msg + 1.
      end.
   end.  /* if available abs_mstr */

   /* NO ERRORS SO CREATE RECORD */

   if error_msg = 0 and create_abs then do:
      /* UPDATE ABS_SHP_DATE WITH SYSTEM DATE. THIS WILL CREATE TAX */
      /* DETAIL RECORDS (TX2D_DET) DURING SHIPPER CONFIRM.          */

      create abs_mstr.

      assign
         abs_mstr.abs_shipfrom = ship_from
         abs_mstr.abs_id = "i" + ship_record.abs_id
                         + ship_part + ship_cust_po
                         + ship_cust_ref + ship_cust_modelyr
                         + ship_lot + ship_ref
         abs_mstr.abs_par_id   = ship_parent
         abs_mstr.abs_item     = ship_part
         abs_mstr.abs_order    = ship_order
         abs_mstr.abs_line     = string(integer(ship_line))
         abs_mstr.abs_site     = ship_site
         abs_mstr.abs_loc      = ship_loc
         abs_mstr.abs_lot      = ship_lot
         abs_mstr.abs_ref      = ship_ref
         abs_mstr.abs_qty      = decimal(ship_qty)
         abs_mstr.abs__qad02   = ship_qty_um
         abs_mstr.abs__qad03   = "1"
         abs_mstr.abs__qad04   = ship_kanban
         abs_mstr.abs__qad05   = ship_cust_po
         abs_mstr.abs_wt_um    = ship_wght_um
         abs_mstr.abs_vol      = decimal(ship_vol)
         abs_mstr.abs_vol_um   = ship_vol_um
         abs_mstr.abs_shp_date = today
         abs_mstr.abs_type     = substring(ship_parent,1,1).

      l_abs_recid = recid(abs_mstr).

      if using_seq_schedules and
         can-find (first so_mstr where
            so_nbr = ship_order  and
            so_seq_order) and
         can-find (first rcs_mstr where
            rcs_shipfrom = ship_from  and
            rcs_shipto = v_ship_to  and
            rcs_active)
      then do:
         {gprunmo.i
            &program=""rcshgwsq.p""
            &module="ASQ"
            &param="""(input l_abs_recid,
                       input v_ship_to,
                       output errors)"""}

         if errors then leave.
      end.

      if using_line_charges then do:
         /* COPY FROM THE SALES ORDER ANY LINE CHARGES */
         {gprunmo.i
            &program = ""sosob1c.p""
            &module = "ACL"
            &param = """(input abs_mstr.abs_id,
                         input abs_mstr.abs_shipfrom,
                         input abs_mstr.abs_order,
                         input integer(abs_mstr.abs_line))"""}
      end. /* IF USING_LINE_CHARGES */

      /* IF THERE ARE LINE LEVEL USER FIELDS COPY THOSE TO THE */
      /* SHIPPER AS WELL.                                      */
      if using_container_charges or using_line_charges then do:
         {gprunmo.i
            &program = ""sosob1b.p""
            &module  = "ACL"
            &param   = """(input abs_mstr.abs_id,
                           input abs_mstr.abs_shipfrom,
                           input ship_record.abs_shipto,
                           input 2)"""}
      end.

      /* FIND TOP-LEVEL PARENT SHIPPER */
      {gprun.i ""gpabspar.p""
         "(abs_recno, 'S', false, output l_recid)" }

      /* TYPE IS SET TO "S" IF NO PARENT RECORD FOUND                   */
      /* TYPE OF CHILD RECORD IS SET ACCORDINGLY IF PARENT RECORD FOUND */

      if l_recid = ? then
         abs_mstr.abs_type = "S".
      else do:
         find anc_abs_mstr where recid(anc_abs_mstr) = l_recid
            no-lock no-error.
         if anc_abs_mstr.abs_type = "R" then
            abs_mstr.abs_type = "R" .
         else
            abs_mstr.abs_type = "S".
      end. /* L_RECID  <> ? */

      /* DETERMINE WEIGHT, VOLUME, QUANTITY CONVERSIONS */
      wt_conv = 1.

      if pt_net_wt_um <> abs_mstr.abs_wt_um then do:

         {gprun.i ""gpumcnv.p""
            "(input pt_net_wt_um,
              input abs_mstr.abs_wt_um,
              input abs_mstr.abs_item,
              output wt_conv)"}

         if wt_conv = ? then wt_conv = 1.
      end.

      vol_conv = 1.

      if pt_size_um <> abs_mstr.abs_vol_um then do:

         {gprun.i ""gpumcnv.p""
            "(input pt_size_um,
              input abs_mstr.abs_vol_um,
              input abs_mstr.abs_item,
              output vol_conv)"}

         if vol_conv = ? then vol_conv = 1.
      end.

      qty_conv = 1.

      if pt_um <> abs_mstr.abs__qad02 then do:

         /* INTERCHANGE THE FIRST TWO PARAMETERS */
         {gprun.i ""gpumcnv.p""
            "(input abs_mstr.abs__qad02,
              input pt_um,
              input abs_mstr.abs_item,
              output qty_conv)"}

         if qty_conv = ? then qty_conv = 1.
      end.

      if ship_net_wt = "" then
         l_abs_nwt = pt_net_wt * wt_conv * abs_mstr.abs_qty * qty_conv.
      else
         l_abs_nwt = decimal(ship_net_wt).

      if ship_wght = "" then
         l_abs_gwt = pt_ship_wt * wt_conv * abs_mstr.abs_qty * qty_conv.
      else
         l_abs_gwt = decimal(ship_wght).

      if ship_vol = "" then
         abs_mstr.abs_vol = pt_size * vol_conv * abs_mstr.abs_qty
                          * qty_conv.

      l_abs_tare_wt = max(l_abs_gwt - l_abs_nwt,0).
      {abspack.i "abs_mstr" 26 22 "l_abs_tare_wt"}

      abs_mstr.abs__qad03 = string(1 / qty_conv).

      find ship_record where ship_record.abs_shipfrom = ship_from
         and ship_record.abs_id = ship_parent exclusive-lock.

      /* ROLL UP THE WEIGHTS, VOLUME */
      WEIGHTS:
      repeat:

         if ship_record.abs_vol_um = "" then
            ship_record.abs_vol_um = abs_mstr.abs_vol_um.

         /* DETERMINE VOLUME UM CONVERSION */
         vol_conv = 1.

         if ship_record.abs_vol_um <> abs_mstr.abs_vol_um
         then do:

            {gprun.i ""gpumcnv.p""
               "(input abs_mstr.abs_vol_um,
                 input ship_record.abs_vol_um,
                 input """",
                 output vol_conv)"}

            if vol_conv = ? then vol_conv = 1.
         end.

         /* ADD TO CURRENT WEIGHTS */
         assign

            ship_record.abs_vol =
               ship_record.abs_vol + abs_mstr.abs_vol * vol_conv.

         /* IF NOT TOPMOST RECORD THEN KEEP GOING */
         if ship_record.abs_par_id <> "" then do:

            find abs_mstr
               where recid(abs_mstr) = recid(ship_record)
               no-lock.

            find ship_record
               where ship_record.abs_shipfrom
               = abs_mstr.abs_shipfrom
               and ship_record.abs_id = abs_mstr.abs_par_id
               exclusive-lock.
         end.

         else leave WEIGHTS.
      end.

      for first abs_mstr
         fields (abs_cons_ship abs_dataset abs_format abs_id abs_inv_mov
                 abs_item abs_line abs_loc abs_lotser abs_order abs_par_id
                 abs_qty abs_ref abs_shipfrom abs_shipto abs_shp_date
                 abs_site abs_type abs_vol abs_vol_um abs_wt_um abs__qad02
                 abs__qad03 abs__qad04 abs__qad05 abs__qad10)
            where recid(abs_mstr) = l_abs_recid no-lock:
      end. /* FOR FIRST ABS_MSTR */

      if available abs_mstr then do:

         /* PASSING "YES" TO THE ADDED INPUT PARAMETER I_CHANGE_NET TO */
         /* ROLL-UP NET WT AND GROSS WT */
         {gprun.i ""icshnwt.p"" "(input recid(abs_mstr),
                                  input l_abs_nwt,
                                  input yes,
                                  input abs_mstr.abs_wt_um)"}

         /* ROLL-UP TARE WT TO GROSS WT. ONLY */
         {gprun.i ""icshnwt.p"" "(input recid(abs_mstr),
                                  input l_abs_tare_wt,
                                  input no,
                                  input abs_mstr.abs_wt_um)"}

      end. /* IF AVAILABLE ABS_MSTR */

      if ship_parent begins("S") then do:
         /* ITEM ADDED TO SHIPPER */
         {pxmsg.i &MSGNUM = 8289 &ERRORLEVEL = 1 &MSGARG1 = ship_part}
      end.

      else do:
         /* ITEM ADDED TO CONTAINER: */
         {pxmsg.i &MSGNUM = 8290 &ERRORLEVEL = 1 &MSGARG1 = ship_part}
      end.

   end. /* IF ERROR_MSG <> 0 */

   else do:
      if error_msg <> 0 then do:
         /* # ERRORS OCCURRED # NOT ADDED */
         {pxmsg.i
            &MSGNUM = 766
            &ERRORLEVEL = 4
            &MSGARG1 = string(error_msg)
            &MSGARG2 = getTermLabel(""ITEM"",10)
            }
      end.
   end.

end. /* SHIP_TYPE = "I" */

{rcinvcon.i}
